﻿<UserControl xmlns:my="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Extended"
    x:Class="SilverlightApplication1.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:SilverlightApplication1">
    <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
        <Grid x:Name="LayoutRoot" ShowGridLines="False" Style="{StaticResource BackGrid}">
            <Grid.RowDefinitions>
                <!-- This is fixed to keep the fields aligned of sign in and those of search -->
                <RowDefinition Height="60"/><!--1.3*-->
                <RowDefinition Height="10*"/>
                <RowDefinition Height="0.6*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="110"/><!--1.5* (Probar con 1.8*)-->
                <ColumnDefinition Width="5*"/><!--6*-->
                <ColumnDefinition Width="1.2*"/>
                <ColumnDefinition Width="2*"/>
            </Grid.ColumnDefinitions>
            
            <!-- LAYOUTROOT - Row=0 , Column=0 -->
            <!-- PopUp -->
            <Popup x:Name="popUpMessage" Grid.RowSpan="3" Grid.ColumnSpan="4">
                <Grid x:Name="backGround" Background="#10000000"  Margin="0" RenderTransformOrigin="0.5,0.5">
                    <Grid.Resources>
                        <Storyboard x:Name="SBLoad" AutoReverse="True" RepeatBehavior="Forever">
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
                                <SplineDoubleKeyFrame KeyTime="00:00:02" Value="170"/>
                                <!--Value="170"-->
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
                                <SplineDoubleKeyFrame KeyTime="00:00:02" Value="358.403"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>

                        <Storyboard x:Name="closeMessage">
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="backGround" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" BeginTime="00:00:00">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.4000000" Value="0">
                                    <SplineDoubleKeyFrame.KeySpline>
                                        <KeySpline ControlPoint1="0.842999994754791,0" ControlPoint2="0.694000005722046,1"/>
                                    </SplineDoubleKeyFrame.KeySpline>
                                </SplineDoubleKeyFrame>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="backGround" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" BeginTime="00:00:00">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.4000000" Value="0">
                                    <SplineDoubleKeyFrame.KeySpline>
                                        <KeySpline ControlPoint1="0.842999994754791,0" ControlPoint2="0.694000005722046,1"/>
                                    </SplineDoubleKeyFrame.KeySpline>
                                </SplineDoubleKeyFrame>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="backGround" Storyboard.TargetProperty="(UIElement.Opacity)" BeginTime="00:00:00">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.4000000" Value="0.275"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>

                        <Storyboard x:Name="openMessage">
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="backGround" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" BeginTime="00:00:00">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.4000000" Value="1">
                                    <SplineDoubleKeyFrame.KeySpline>
                                        <KeySpline ControlPoint1="0.842999994754791,0" ControlPoint2="0.694000005722046,1"/>
                                    </SplineDoubleKeyFrame.KeySpline>
                                </SplineDoubleKeyFrame>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="backGround" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" BeginTime="00:00:00">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.4000000" Value="1">
                                    <SplineDoubleKeyFrame.KeySpline>
                                        <KeySpline ControlPoint1="0.842999994754791,0" ControlPoint2="0.694000005722046,1"/>
                                    </SplineDoubleKeyFrame.KeySpline>
                                </SplineDoubleKeyFrame>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="backGround" Storyboard.TargetProperty="(UIElement.Opacity)" BeginTime="00:00:00">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.4000000" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </Grid.Resources>
                        
                    <Grid.RenderTransform>
                        <TransformGroup>
                            <ScaleTransform>
                                <ScaleTransform.ScaleX>0</ScaleTransform.ScaleX>
                                <ScaleTransform.ScaleY>0</ScaleTransform.ScaleY>
                            </ScaleTransform>
                            <SkewTransform/>
                            <RotateTransform/>
                            <TranslateTransform/>
                        </TransformGroup>
                    </Grid.RenderTransform>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="auto"/>
                    </Grid.ColumnDefinitions>
                    <Border x:Name="PopUpLoading" Visibility="Collapsed" Style="{StaticResource BackBorderLoading}"
                            Width="210" Height="60" Padding="10,10,10,10" CornerRadius="25,25,25,25"
                            HorizontalAlignment="Center" VerticalAlignment="Center">
                        <Canvas>
                            <Rectangle RadiusX="10" RadiusY="10"
                                HorizontalAlignment="Center" VerticalAlignment="Center"
                                Height="20" Width="190" Stroke="Black" StrokeThickness="1"/>
                            <Rectangle Height="20" Width="20"
                                RadiusX="20" RadiusY="20" Stroke="Blue" StrokeThickness="1"
                                x:Name="rectangle" RenderTransformOrigin="0.5,0.5">
                                <Rectangle.Fill>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#FF000000"/>
                                        <GradientStop Color="#FFFFFFFF" Offset="1"/>
                                    </LinearGradientBrush>
                                </Rectangle.Fill>
                                <Rectangle.RenderTransform>
                                    <TransformGroup>
                                        <ScaleTransform/>
                                        <SkewTransform/>
                                        <RotateTransform/>
                                        <TranslateTransform/>
                                    </TransformGroup>
                                </Rectangle.RenderTransform>
                            </Rectangle>
                            <TextBlock Canvas.Left="70" Canvas.Top="30" Text="Loading..."/>
                        </Canvas>
                    </Border>

                    <Border x:Name="PopUpBox" Style="{StaticResource BackBorderRadial}"
                            Width="350" Height="250" Padding="10,10,10,10" CornerRadius="25,25,25,25">
                        <StackPanel x:Name="PopUpBoxContent" Height="Auto" Width="Auto"
                                    Orientation="Vertical">
                            <Button x:Name="btnCloseMessage" Margin="0,2,2,0"
                                    Foreground="Black" Background="Black"
                                    Height="15" Width="15"
                                    VerticalAlignment="Top" HorizontalAlignment="Right"
                                    Content="X" FontSize="10" TextAlignment="Center"
                                    Click="btnCloseMessage_Click"/>
                            
                            <!-- Amazon SignIn controls -->
                            <Grid x:Name="SignInPopUp" ShowGridLines="False" Visibility="Collapsed">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="0.6*"/>
                                    <RowDefinition Height="0.6*"/>
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height="*"/>
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <TextBlock x:Name="txtAmazonKeyPopUp" Grid.Row="0"
                                           Text="Amazon Key" Foreground="Black" FontSize="11"
                                           HorizontalAlignment="Center" VerticalAlignment="Center"
                                           FontFamily="Verdana" Margin="5"/>
                                <TextBox x:Name="txtKeyPopUp" Grid.Row="1" Width="200"
                                         Margin="5,0,5,0" FontSize="11" FontFamily="Verdana"
                                         KeyDown="txtKey_KeyDown" TextChanged="txtKey_TextChanged"/>
                                <HyperlinkButton x:Name="hlkSignInPopUp" Grid.Row="2"
                                                 Foreground="SteelBlue" HorizontalAlignment="Center"
                                                 Content="Sign In" FontFamily="Verdana"  Margin="5"
                                                 Click="hlkSignIn_Click" ClickMode="Press"/>
                            </Grid>


                            <ItemsControl x:Name="icMoreInfoPopUp" Grid.Row="1">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal" Margin="5">
                                            <Image Source="{Binding MediumImage}"/>
                                            
                                            <StackPanel Orientation="Vertical" Margin="5">
                                                <TextBlock Text="{Binding Title}" FontWeight="Bold" Margin="3,3,3,3"
                                                           MaxWidth="150" TextWrapping="Wrap"/>
                                                <TextBlock Text="{Binding Author}" Margin="3,3,3,3"
                                                           MaxWidth="150" TextWrapping="Wrap"/>
                                                <StackPanel Orientation="Horizontal" Margin="3,3,3,3">
                                                    <TextBlock Text="("/>
                                                    <TextBlock Text="Publisher" FontWeight="Bold"/>
                                                    <TextBlock Text=" - "/>
                                                    <TextBlock Text="{Binding Publisher}"
                                                               MaxWidth="200" TextWrapping="Wrap"/>
                                                    <TextBlock Text=")"/>
                                                </StackPanel>
                                                <StackPanel Orientation="Horizontal" Margin="3,3,3,3">
                                                    <TextBlock Text="Price: " FontWeight="Bold"/>    
                                                    <TextBlock Text="{Binding ListPrice.CurrencyCode}"/>
                                                    <TextBlock Text=" "/>
                                                    <TextBlock Text="{Binding ListPrice.FormattedPrice}"/>
                                                </StackPanel>
                                                <StackPanel Orientation="Horizontal">
                                                    <TextBlock Text="Publication Date " FontWeight="Bold"/>    
                                                    <TextBlock Text="{Binding PublicationDate}"/>
                                                </StackPanel>
                                                <StackPanel Orientation="Horizontal">
                                                    <TextBlock Text="Release Date " FontWeight="Bold"/>    
                                                    <TextBlock Text="{Binding ReleaseDate}"/>
                                                </StackPanel>
                                                <StackPanel Orientation="Horizontal">
                                                    <TextBlock Text="ISBN " FontWeight="Bold"/>    
                                                    <TextBlock Text="{Binding Isbn}"/>
                                                </StackPanel>
                                            </StackPanel>
                                        </StackPanel>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </StackPanel>
                    </Border>
                </Grid>
            </Popup>
            <!-- End of PopUp -->
            
            <!-- LAYOUTROOT - Row=0 , Column=0 -->
            <!-- Amazon SignIn control -->
            <HyperlinkButton x:Name="hlkSignIn" Foreground="SteelBlue"
                             HorizontalAlignment="Left" VerticalAlignment="Center"
                             FontFamily="Verdana" Margin="5,5,5,5"
                             Click="hlkSignInAgain_Click" ClickMode="Press"/>
                        
            <!-- LayoutRoot - Row=0 , Column=1 -->      
            <TextBox x:Name="txtQuery" Grid.Column="1" Height="20" VerticalAlignment="Bottom" Margin="5"
                     FontFamily="Verdana"
                     KeyDown="txtQueryKeyDown"/>
            
            <local:AdvancedSearch x:Name="uctrlAdvSearch" Visibility="Collapsed"
                                  Grid.Column="1" Grid.RowSpan="2" VerticalAlignment="Top"/>
            
            <!-- LayoutRoot - Row=0 , Column=2 -->
            <Button x:Name="btnSearch" Content="Search" Click="Search_Click" Grid.Column="2" Height="20"
                HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="7,5,5,5" MaxWidth="100"
                FontFamily="Verdana" Style="{StaticResource BackButtonSimple}"/>

            <!-- LayoutRoot - Row=0 , Column=3 -->
            <HyperlinkButton x:Name="hlnkEEUU" Click="ChangeLanguage" Margin="5" Height="15"
                Grid.Column="3"  VerticalAlignment="Top" HorizontalAlignment="Right">
                <HyperlinkButton.Content>
                    <Image x:Name="imgEEUU" Source="images/EEUU.jpg"/>
                </HyperlinkButton.Content>
            </HyperlinkButton>
            <HyperlinkButton x:Name="hlnkES" Click="ChangeLanguage" Margin="5" Height="15"
                Grid.Column="3"  VerticalAlignment="Top" HorizontalAlignment="Right">
                <HyperlinkButton.Content>
                    <Image x:Name="imgES" Source="images/ES.jpg"/>
                </HyperlinkButton.Content>
            </HyperlinkButton>
            <HyperlinkButton x:Name="hlnkAdvSearch" Content="Advanced Search" Click="Advanced" Margin="5"
                         Grid.Column="3"  VerticalAlignment="Bottom" HorizontalAlignment="Left"
                         FontFamily="Verdana" Foreground="White"/>

            <!-- LayoutRoot - Row=1 , Column=0 -->
            <!-- Contains buttons to choose the search option (the option available is Books)-->
            <Grid x:Name="grdButtons" Grid.Row="1">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" MaxHeight="150"/>
                    <RowDefinition Height="*" MaxHeight="150"/>
                    <RowDefinition Height="*" MaxHeight="150"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Grid.Resources>
                    <!-- Storyboard used by buttons in grid at the Left (MouseEnter event) -->
                    <Storyboard x:Name="renderBigger" SpeedRatio="4">
                        <DoubleAnimation Storyboard.TargetProperty="(ScaleTransform.ScaleX)" From="1" To="1.5"/>
                        <DoubleAnimation Storyboard.TargetProperty="(ScaleTransform.ScaleY)" From="1" To="1.5"/>
                    </Storyboard>
                    <!-- Storyboard used by buttons in grid at the Left (MouseLeave event) -->
                    <Storyboard x:Name="renderLower" SpeedRatio="4">
                        <DoubleAnimation Storyboard.TargetProperty="(ScaleTransform.ScaleX)" From="1.5" To="1"/>
                        <DoubleAnimation Storyboard.TargetProperty="(ScaleTransform.ScaleY)" From="1.5" To="1"/>
                    </Storyboard>
                </Grid.Resources>
                <!-- Books -->
                <Button x:Name="btnBooks" VerticalAlignment="Center" Margin="2" Width="75" Height="75"
                    MouseEnter="btnBooksToBigger" MouseLeave="btnBooksToLower"
                    FontFamily="Verdana">
                    <Button.RenderTransform>
                        <ScaleTransform x:Name="rdrBooks" ScaleX="1" ScaleY="1"/>
                    </Button.RenderTransform>
                    <Button.Content>
                        <Image x:Name="imgBooks" Source="images/imgLibros.jpg"/>
                    </Button.Content>
                    <Button.Clip>
                        <EllipseGeometry x:Name="egBooks" RadiusX="30" RadiusY="30" Center="37.5,37.5"/>
                    </Button.Clip>
                </Button>
                <!-- About... -->
                <Button x:Name="btnAbout1" Grid.Row="1" VerticalAlignment="Center" Margin="2"
                        Width="75" Height="75" MouseEnter="btnAbout1ToBigger" MouseLeave="btnAbout1ToLower"
                        FontFamily="Verdana" Style="{StaticResource BackButtonSimple}">
                    <Button.RenderTransform>
                        <ScaleTransform x:Name="rdrAbout1" ScaleX="1" ScaleY="1"/>
                    </Button.RenderTransform>
                    <Button.Clip>
                        <EllipseGeometry x:Name="egAbout1" RadiusX="30" RadiusY="30" Center="37.5,37.5"/>
                    </Button.Clip>
                </Button>
                <!-- About... -->
                <Button x:Name="btnAbout2" Grid.Row="2" VerticalAlignment="Center" Margin="2"
                        Width="75" Height="75" MouseEnter="btnAbout2ToBigger" MouseLeave="btnAbout2ToLower"
                        FontFamily="Verdana" Style="{StaticResource BackButton}">
                    <Button.RenderTransform>
                        <ScaleTransform x:Name="rdrAbout2" ScaleX="1" ScaleY="1"/>
                    </Button.RenderTransform>
                    <Button.Clip>
                        <EllipseGeometry x:Name="egAbout2" RadiusX="30" RadiusY="30" Center="37.5,37.5"/>
                    </Button.Clip>
                </Button>
            </Grid>
            
            <!-- LayoutRoot - Row=1 , Column=1 -->
            <Grid x:Name="grdLstResult" ShowGridLines="False" Grid.Column="1" Grid.Row="1">
                <Grid.RowDefinitions>
                    <RowDefinition Height="20"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="20"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="2*"/> <!-- Used as margin -->
                    <ColumnDefinition Width="0.2*"/> <!-- First page -->
                    <ColumnDefinition Width="0.2*"/> <!-- Previous page-->
                    <ColumnDefinition Width="Auto"/> <!-- Pages information -->
                    <ColumnDefinition Width="0.2*"/> <!-- Next page -->
                    <ColumnDefinition Width="0.2*"/> <!-- Last page -->
                    <ColumnDefinition Width="2*"/> <!-- Used as margin -->
                </Grid.ColumnDefinitions>
                <HyperlinkButton x:Name="hlkFPageT" Grid.Column="1" Foreground="SteelBlue"
                                 Content="|&lt;" FontFamily="Verdana" HorizontalAlignment="Center"
                                 Visibility="Collapsed" Click="hlkFPage_Click" ClickMode="Press"/>
                <HyperlinkButton x:Name="hlkPPageT" Grid.Column="2" Foreground="SteelBlue"
                                 Content="&lt;" FontFamily="Verdana" HorizontalAlignment="Center"
                                 Visibility="Collapsed" Click="hlkPPage_Click" ClickMode="Press"/>
                <TextBlock x:Name="txtPagesInfoT" Grid.Column="3" FontFamily="Verdana"
                           Text=" 1-10 of 95 " Foreground="SteelBlue"
                           Visibility="Collapsed"/>
                <HyperlinkButton x:Name="hlkNPageT" Grid.Column="4" Foreground="SteelBlue"
                                 Content=">" FontFamily="Verdana" HorizontalAlignment="Center"
                                 Visibility="Collapsed" Click="hlkNPage_Click" ClickMode="Press"/>
                <HyperlinkButton x:Name="hlkLPageT" Grid.Column="5" Foreground="SteelBlue"
                                 Content=">|" FontFamily="Verdana" HorizontalAlignment="Center"
                                 Visibility="Collapsed" Click="hlkLPage_Click" ClickMode="Press"/>
                <!-- The items will be loaded on code behind -->
                <ListBox x:Name="lstResult" Grid.Row="1" Grid.ColumnSpan="7"
                         Margin="5" Visibility="Collapsed" FontFamily="Verdana"
                         SelectionChanged="lstResultSelectionChanged"
                         MaxWidth="500" MinWidth="200">
                    <!--Grid.Column="1"-->
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" >
                                <!-- Thumbnail Preview -->
                                <Image Source="{Binding MediumImage}"
                                       MouseLeftButtonDown="ShowItemInformation"/>

                                <!-- Info -->
                                <StackPanel Orientation="Vertical">
                                    <TextBlock Text="{Binding Title}" FontWeight="Bold" Margin="3,3,3,3"
                                                   MaxWidth="350" TextWrapping="Wrap"/>
                                    <TextBlock Text="{Binding Author}" Margin="3,3,3,3"
                                               MaxWidth="350" TextWrapping="Wrap"/>
                                    <StackPanel Orientation="Horizontal" Margin="3,3,3,3">
                                        <TextBlock Text="("/>
                                        <TextBlock Text="Publisher" FontWeight="Bold"/>
                                        <TextBlock Text=" - "/>
                                        <TextBlock Text="{Binding Publisher}"
                                                   MaxWidth="300" TextWrapping="Wrap"/>
                                        <TextBlock Text=")"/>
                                    </StackPanel>
                                    <StackPanel Orientation="Horizontal" Margin="3,3,3,3">
                                        <TextBlock Text="Price: " FontWeight="Bold"/>    
                                        <TextBlock Text="{Binding ListPrice.CurrencyCode}"/>
                                        <TextBlock Text=" "/>
                                        <TextBlock Text="{Binding ListPrice.FormattedPrice}"/>
                                    </StackPanel>
                                </StackPanel>
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
                <HyperlinkButton x:Name="hlkFPageB" Grid.Row="2" Grid.Column="1" Foreground="SteelBlue"
                                 Content="|&lt;" FontFamily="Verdana" HorizontalAlignment="Center"
                                 Visibility="Collapsed" Click="hlkFPage_Click" ClickMode="Press"/>
                <HyperlinkButton x:Name="hlkPPageB" Grid.Row="2" Grid.Column="2" Foreground="SteelBlue"
                                 Content="&lt;" FontFamily="Verdana" HorizontalAlignment="Center"
                                 Visibility="Collapsed" Click="hlkPPage_Click" ClickMode="Press"/>
                <TextBlock x:Name="txtPagesInfoB" Grid.Row="2" Grid.Column="3" FontFamily="Verdana"
                           Text=" 1-10 of 95 " Foreground="SteelBlue"
                           Visibility="Collapsed"/>
                <HyperlinkButton x:Name="hlkNPageB" Grid.Row="2" Grid.Column="4" Foreground="SteelBlue"
                                 Content=">" FontFamily="Verdana" HorizontalAlignment="Center"
                                 Visibility="Collapsed" Click="hlkNPage_Click" ClickMode="Press"/>
                <HyperlinkButton x:Name="hlkLPageB" Grid.Row="2" Grid.Column="5" Foreground="SteelBlue"
                                 Content=">|" FontFamily="Verdana" HorizontalAlignment="Center"
                                 Visibility="Collapsed" Click="hlkLPage_Click" ClickMode="Press"/>
            </Grid>

            
            <!-- LayoutRoot - Row=1 , Column=2 y Column=3 -->
            <!-- Advanced Search  -->  
            <Grid x:Name="AdvContainer" Grid.Column="2" Grid.Row="1" Grid.ColumnSpan="2" Margin="5,5,5,5"
                  Height="Auto" Width="Auto">
                <Grid x:Name="grdAdvSearch" Visibility="Collapsed" 
                  ShowGridLines="False" HorizontalAlignment="Center" VerticalAlignment="Top"
                  Opacity="0.7">
                    <Grid.Background>
                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                            <GradientStop Color="#FF4682B4"/>
                            <GradientStop Color="#FFF0FFFF" Offset="1"/>
                            <GradientStop Color="#FF4A86B9" Offset="0.464"/>
                            <GradientStop Color="#FF4784B7" Offset="0.317"/>
                            <GradientStop Color="#FFCDD7F0" Offset="0.857"/>
                        </LinearGradientBrush>
                    </Grid.Background>
                    <Grid.Resources>
                        <Storyboard x:Name="toVisible" Storyboard.TargetName="grdAdvSearch"
                                    SpeedRatio="7" Duration="00:00:05.00">
                            <DoubleAnimation Storyboard.TargetProperty="(Grid.Height)" By="150" From="0" To="460"/>
                            <DoubleAnimation Storyboard.TargetProperty="(Grid.Width)" By="100" From="0" To="290"/>
                        </Storyboard>
                        <Storyboard x:Name="toNotVisible" Storyboard.TargetName="grdAdvSearch"
                                    SpeedRatio="7" Duration="00:00:05.00">
                            <DoubleAnimation Storyboard.TargetProperty="(Grid.Height)" By="150" To="0"/>
                            <DoubleAnimation Storyboard.TargetProperty="(Grid.Width)" By="100" To="0"/>
                        </Storyboard>
                    </Grid.Resources>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="3*"/>
                    <RowDefinition Height="6*"/>
                    <RowDefinition Height="0.6*"/>
                </Grid.RowDefinitions>
            
                <TextBlock x:Name="lblAdvanced" Grid.Row="0" VerticalAlignment="Bottom"
                           HorizontalAlignment="Center" Margin="5,5,5,5" Text="Advanced Search"
                           TextAlignment="Center" FontFamily="Verdana" FontSize="16" Foreground="Azure"/>   
                <Grid x:Name="grdSort" Grid.Row="1" ShowGridLines="False" Margin="2">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>   
                        <RowDefinition Height="*"/> 
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>   
                    <TextBlock x:Name="lblSort" Grid.Row="0" Grid.ColumnSpan="2" Margin="3,0,3,0"
                               HorizontalAlignment="Left" VerticalAlignment="Bottom"
                               Text="Sort by" TextAlignment="Left" FontFamily="Verdana" FontSize="14" FontStyle="Italic"/>
                    <RadioButton x:Name="rbtPrice" Grid.Row="1" Grid.Column="0" Margin="3" GroupName="grpSort"
                                 VerticalAlignment="Center" HorizontalAlignment="Left"
                                 Content="List Price" FontFamily="Verdana" FontSize="12"/>
                    <RadioButton x:Name="rbtPublDate" Grid.Row="2" Grid.Column="0" Margin="3" GroupName="grpSort"
                                 VerticalAlignment="Center" HorizontalAlignment="Left"                             
                                 Content="Publication Date" FontFamily="Verdana" FontSize="12"/>    
                    <RadioButton x:Name="rbtTitle" Grid.Row="3" Grid.Column="0" Margin="3" GroupName="grpSort"
                                 VerticalAlignment="Center" HorizontalAlignment="Left"
                                 Content="Title" FontFamily="Verdana" FontSize="12"/>
                    <RadioButton x:Name="rbtAsc" Grid.Row="1" Grid.Column="1" Margin="3" GroupName="grpOrder"
                                 VerticalAlignment="Center" HorizontalAlignment="Left"
                                 Content="Ascending" FontFamily="Verdana" FontSize="12"/>
                    <RadioButton x:Name="rbtDesc" Grid.Row="2" Grid.Column="1" Margin="3" GroupName="grpOrder"
                                 VerticalAlignment="Center" HorizontalAlignment="Left"
                                 Content="Descending" FontFamily="Verdana" FontSize="12"/>
                </Grid>

                <Grid x:Name="grdFiltered" Grid.Row="2" Background="Transparent"  ShowGridLines="False" Margin="3">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="8*"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="8*"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions> 
                    <TextBlock x:Name="lblFiltered" Grid.Row="0" Grid.ColumnSpan="2" Margin="3,0,3,0"
                               HorizontalAlignment="Left" VerticalAlignment="Center"
                               Text="Filtered by" TextAlignment="Left"
                               FontFamily="Verdana" FontSize="14" FontStyle="Italic"/>
                    <Grid x:Name="grdFilteredOptions" Grid.Row="1" Background="Transparent" ShowGridLines="False">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="3*"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>            
                        <TextBlock x:Name="lblAuthor" Grid.Row="0" Margin="3,0,3,0"
                               HorizontalAlignment="Left" VerticalAlignment="Center"
                               Text="Author:" TextAlignment="Left" FontFamily="Verdana" FontSize="10"/>
                        <TextBox x:Name="txtAuthor" Grid.Row="0" Grid.Column="1"
                                 HorizontalAlignment="Stretch" VerticalAlignment="Center"
                                 TextAlignment="Left" FontFamily="Verdana" FontSize="10"/>
                        <TextBlock x:Name="lblPublisher" Grid.Row="1" Margin="3,0,3,0"
                               HorizontalAlignment="Left" VerticalAlignment="Center"
                               Text="Publisher:" TextAlignment="Left" FontFamily="Verdana" FontSize="10"/>
                        <TextBox x:Name="txtPublisher" Grid.Row="1" Grid.Column="1" 
                                 HorizontalAlignment="Stretch" VerticalAlignment="Center"
                                 TextAlignment="Left" FontFamily="Verdana" FontSize="10"/>
                        <TextBlock x:Name="lblTitle" Grid.Row="2" Margin="3,0,3,0"
                               HorizontalAlignment="Left" VerticalAlignment="Center"
                               Text="Title:" TextAlignment="Left" FontFamily="Verdana" FontSize="10"/>
                        <TextBox x:Name="txtTitle" Grid.Row="2" Grid.Column="1" 
                                 HorizontalAlignment="Stretch" VerticalAlignment="Center"
                                 TextAlignment="Left" FontFamily="Verdana" FontSize="10"/>
                        <TextBlock x:Name="lblCategory" Grid.Row="3" Margin="3,0,3,0"
                               HorizontalAlignment="Left" VerticalAlignment="Center"
                               Text="Category:" TextAlignment="Left" FontFamily="Verdana" FontSize="10"/>
                        <TextBox x:Name="txtCategory" Grid.Row="3" Grid.Column="1" 
                                 HorizontalAlignment="Stretch" VerticalAlignment="Center"
                                 TextAlignment="Left" FontFamily="Verdana" FontSize="10"/>
                        <Grid Grid.Row="4" Grid.ColumnSpan="2" Margin="3,0,3,0">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions> 
                        <TextBlock x:Name="lblCondition"
                               HorizontalAlignment="Left" VerticalAlignment="Center"
                               Text="Condition:" TextAlignment="Left" FontFamily="Verdana" FontSize="10"/>
                        <CheckBox x:Name="chkUsed" Grid.Column="1"
                                  VerticalAlignment="Center" HorizontalAlignment="Left"
                                  Content="Used" TextAlignment="Left" FontFamily="Verdana" FontSize="10"/>
                        <CheckBox x:Name="chkCollectible" Grid.Row="1" Grid.Column="1"
                                  VerticalAlignment="Center" HorizontalAlignment="Left"
                                  Content="Collectible" TextAlignment="Left" FontFamily="Verdana" FontSize="10"/>
                        <CheckBox x:Name="chkRefurbished" Grid.Row="2" Grid.Column="1"
                                  VerticalAlignment="Center" HorizontalAlignment="Left"
                                  Content="Refurbished" TextAlignment="Left" FontFamily="Verdana" FontSize="10"/>
                        </Grid>
                        <TextBlock x:Name="lblKeyword" Grid.Row="5" Margin="3,0,3,0"
                               HorizontalAlignment="Left" VerticalAlignment="Center"
                               Text="Keyword:" TextAlignment="Left" FontFamily="Verdana" FontSize="10"/>
                        <TextBox x:Name="txtKeyword" Grid.Row="5" Grid.Column="1" 
                                 HorizontalAlignment="Stretch" VerticalAlignment="Center"
                                 TextAlignment="Left" FontFamily="Verdana" FontSize="10"/>
                        <TextBlock x:Name="lblMaxPrice" Grid.Row="6" Margin="3,0,3,0"
                               HorizontalAlignment="Left" VerticalAlignment="Center"
                               Text="Maximum Price:" TextAlignment="Left" FontFamily="Verdana" FontSize="10"/>
                        <TextBox x:Name="txtMaxPrice" Grid.Row="6" Grid.Column="1"
                                 HorizontalAlignment="Stretch" VerticalAlignment="Center"
                                 TextAlignment="Left" FontFamily="Verdana" FontSize="10"/>
                        <TextBlock x:Name="lblMinPrice" Grid.Row="7" Margin="3,0,3,0"
                               HorizontalAlignment="Left" VerticalAlignment="Center"
                               Text="Minimum Price:" TextAlignment="Left" FontFamily="Verdana" FontSize="10"/>
                        <TextBox x:Name="txtMinPrice" Grid.Row="7" Grid.Column="1"
                                 HorizontalAlignment="Stretch" VerticalAlignment="Center"
                                 TextAlignment="Left" FontFamily="Verdana" FontSize="10"/>
                    </Grid>
                </Grid>
                <Button x:Name="btnConfirm" Grid.Row="3" Margin="0,0,45,0" Height="26" Width="26"
                        MouseEnter="btnConfirmToLight" MouseLeave="btnConfirmToDark" Click="Advanced">
                    <Button.Clip>
                        <EllipseGeometry RadiusX="8" RadiusY="8" Center="13,13"/>
                    </Button.Clip>
                    <Button.Content>
                        <Grid x:Name="imgsGreen">
                            <Image x:Name="imgDarkGreen" Source="images/button1_0.jpg" Height="26" Width="26"
                                   HorizontalAlignment="Center" VerticalAlignment="Center"/>
                            <Image x:Name="imgLightGreen" Source="images/button1_1.jpg" Height="26" Width="26"
                                   HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="Collapsed"/>
                        </Grid>
                    </Button.Content>
                </Button>
                <Button x:Name="btnCancel" Grid.Row="3" Height="26" Width="26" Margin="20,0,0,0"
                        MouseEnter="btnCancelToLight" MouseLeave="btnCancelToDark" Click="Advanced">
                    <Button.Clip>
                        <EllipseGeometry RadiusX="8" RadiusY="8" Center="13,13"/>
                    </Button.Clip>
                    <Button.Content>
                        <Grid x:Name="imgsRed">
                            <Image x:Name="imgDarkRed" Source="images/buttonr_0.jpg" Height="26" Width="26"
                                   HorizontalAlignment="Center" VerticalAlignment="Center"/>
                            <Image x:Name="imgLightRed" Source="images/buttonr_1.jpg" Height="26" Width="26"
                                   HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="Collapsed"/>
                        </Grid>
                    </Button.Content>
                </Button>
            </Grid>
            </Grid>            
            
        </Grid>
    </ScrollViewer>
</UserControl>
